<?php
abstract class Notification{
	
	protected $id_notification;
	protected $id_user_object;
	protected $id_user_subject;
	protected $state;
	protected $time;
	
	protected function __construct($map){
		$this->id_notification = isset($map['id_notification']) ? $map['id_notification'] : null;
		$this->id_user_object = isset($map['id_user_object']) ? $map['id_user_object'] : null;
		$this->id_user_subject = isset($map['id_user_subject']) ? $map['id_user_subject'] : null;
		$this->state = isset($map['state']) ? $map['state'] : NOTIFICATION_NEW;
		$this->time = isset($map['time']) ? $map['time'] : date("Y-m-d H:i:s");
	}
	
	public static function initialize($map){
		$notification_type = isset($map['notification_type']) ? $map['notification_type'] : null;
		switch($notification_type){
			case DEMANDE_AJOUT_AMI:
				return new Notification_AddFriend($map);
				break;
			case DEMANDE_AJOUT_AMI_ACCEPTEE:
				return new Notification_AcceptFriend($map);
				break;
			default:
				throw new Exception("Type de Notification inconnu");	
		}
	}
	
	public function update($data){
		if (isset($data['state']))
			$this->setState($data['state']);
	}
	
	public function getIdNotification(){
		return $this->id_notification;
	}
	
	public function getIdUserObject(){
		return $this->id_user_object;
	}
	
	public function getIdUserSubject(){
		return $this->id_user_subject;
	}
	
	public function getState(){
		return $this->state;
	}
	
	public function setState($state){
		$this->state = $state;
	}
	
	public function getTime(){
		return $this->time;
	}
	
	public abstract function getNotificationType();
	
	public abstract function getUserSubjectMsg();
	
	public abstract function getMessageTitle();
	
	public abstract function getNotificationMsg($date=false);

	
}


?>